<%@page import="com.baozun.util.StringUtil"%>
<%@page import="com.baozun.util.items.SelectSet"%>
<%@page import="com.baozun.util.SpringBeanUtil"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="com.baozun.util.ReloadablePropertiesUtil"%>
<%@page import="com.baozun.model.TUser"%>
<%@page import="com.baozun.util.PageData"%>
<%@page import="com.baozun.util.CommonConst"%>
<%@page import="java.util.List"%>
<%@page import="com.baozun.model.TWorkrecord"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Static &amp; Dynamic Tables" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- basic styles -->

<link href="../assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="../assets/css/font-awesome.min.css" />
<link rel="stylesheet" href="../assets/css/font.css" />
<link rel="stylesheet" href="../assets/css/ace.min.css" />
<link rel="stylesheet" href="../assets/css/ace-rtl.min.css" />
<link rel="stylesheet" href="../assets/css/ace-skins.min.css" />

<script src="../assets/js/ace-extra.min.js"></script>
<style type="text/css">
.page-header{
	padding-top:1px;
	padding-bottom:2px;
}

.table thead tr{
	background: #307ecc;
	color: #ffffff;
}
.page-header{
	padding-top:1px;
	padding-bottom:2px;
}
</style>
</head>
<%
//用来获取自定义的颜色值字符串
ReloadablePropertiesUtil properties = (ReloadablePropertiesUtil)SpringBeanUtil.getBean(request, "workrecordCongifService");

//获取传参
Map<String,TContact> contactMap = (Map<String,TContact>)application.getAttribute(CommonConst.CONTEXT_CONTACT_MAP);
PageData<TWorkrecord> infoList = (PageData<TWorkrecord>)request.getAttribute(CommonConst.REQUEST_WORKRECORD_LIST);
int currPage = infoList.getPage();
int pageSize = infoList.getPages();
%>
<body style="min-height: 450px;">
	<div class="page-content">
		<div class="page-header">
			<h1>
				记录
			</h1>
		</div>
		<a class="btn btn-sm btn-success" href="workrecord_add.do" target="workrecord_iframe"><i class="icon-plus"></i>新增</a>
		<!-- /.page-header -->
		<div class="row">
			<div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
				<div class="row">
					<div class="col-xs-12">
						<div class="table-responsive">
						
							<table id="sample-table-1"
								class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center">#</th>
										<th class="center">标题</th>
										<th class="center">日期</th>
										<th class="center">提出人</th>
										<th class="center">类型</th>
										<th class="center">优先级</th>
										<th class="center">完成状态</th>
										<th class="center">操作</th>
									</tr>
								</thead>
								<tbody>
								<%
								int index = 1;
								for(TWorkrecord workrecord:infoList){
								    //根据workrecord中的优先级和完成情况得到颜色
								    String urgentColor = properties.loadString("color.green");
								    String finishColor = properties.loadString("color.green");
								    if("3".equals(workrecord.getStUrgentLevel())){
								        urgentColor = properties.loadString("color.red");
								    }else if("2".equals(workrecord.getStUrgentLevel())){
								        urgentColor = properties.loadString("color.yellow");
								    }
								    
								    if("1".equals(workrecord.getStFinishLevel())){
								        finishColor = properties.loadString("color.red");
								    }else if("2".equals(workrecord.getStFinishLevel())){
								        finishColor = properties.loadString("color.yellow");
								    }
								    //得到对应的联系人
								    TContact contact = contactMap.get(workrecord.getStContactId());
								%>
									<tr>
										<td class="center"><%=index++ %></td>
										<td class="center"><%=StringUtil.param2Html(workrecord.getStTitle())%></td>
										<td class="center"><%=StringUtil.param2Html(workrecord.getDtCreateTime(),"yyyy-MM-dd HH:mm:ss")%></td>
										<td class="center"><%=StringUtil.param2Html(contact==null?"":contact.getStContactName())%></td>
										<td class="center"><%=SelectSet.getCaptionById(SelectSet.getWorkrecordType(), workrecord.getStType())%></td>
										<td class="center" style="background: <%=urgentColor%>"><%=SelectSet.getCaptionById(SelectSet.getUrgentLevel(), workrecord.getStUrgentLevel())%></td>
										<td class="center" style="background:<%=finishColor%>"><%=SelectSet.getCaptionById(SelectSet.getFinishLevel(), workrecord.getStFinishLevel())%></td>
										<td class="center" style="width:15%">
											<div>
												<button class="btn btn-xs btn-info" onclick="workrecordEdit('<%=workrecord.getStWorkrecordId()%>')">
													<i class="icon-edit bigger-120"></i>
												</button>
												<button class="btn btn-xs btn-danger" onclick="workrecordDelete('<%=workrecord.getStWorkrecordId()%>')">
													<i class="icon-trash bigger-120"></i>
												</button>
											</div>
										</td>
									</tr>
									<%}%>
								</tbody>
							</table>
							<div align="center">
							<%@include file="../include/pagenumber.jsp" %>
							</div>
						</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /span -->
				</div>
				<!-- /row -->
			</div>
			<!-- /.col -->
		</div>
		<!-- /.row -->
	</div>
	<!-- /.page-content -->
	<script type="text/javascript" src="../assets/js/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="../js/artDialog/artDialog.source.js?skin=default"></script>
<script type="text/javascript" src="../js/artDialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript" src="../js/openDialog.js"></script>
<script type="text/javascript" src="../js/openDialogcustom.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    window.iframeResize = function(){  
        var  dvalue = 0;  
       // if($.browser.safari){  
       //     dvalue = 67; 
       // }  
        parent.document.getElementById("workrecord_iframe").scrolling = "yes";  
        parent.document.getElementById("workrecord_iframe").height = "";  
        parent.document.getElementById("workrecord_iframe").style.height = "";  
        parent.document.getElementById("workrecord_iframe").height = document.body.scrollHeight + dvalue;  
      };
      if(window.iframeResize){  
          window.iframeResize();  
      }
      parent.iFrameHeight();
});
function pagechange(page){
	parent.document.workrecord_search_form.currentPage.value=page;
	process();
}
//刷新查询
function process(){
	parent.document.workrecord_search_form.submit();
}
//删除
function workrecordDelete(id){
	if(confirm("确认删除该日志吗?")){
		$.ajax({
			url:'workrecord_delete.do',
			data:{ST_WORKRECORD_ID:id},
			method:'post',
			dataType:"text",
			success:function(data,status){
				if("right" == data){
					process();
				}else{
					alert("删除失败！");
				}
			}	
	});
	}
}

//编辑日志
function workrecordEdit(id){
	window.location="workrecord_edit.do?stWorkrecordId="+id;
}
</script>
</body>
</html>